package gui;

import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ResultsWindow extends JFrame{
	private static final long serialVersionUID = 1L;

	private JTextArea output;
	
	public ResultsWindow(String title) {
		super();
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		output = new JTextArea();
		output.setEditable(false);
		JScrollPane scrollPane = new JScrollPane(output);
		this.add(scrollPane);
		
		setTitle(title);
		//setResizable(false);
		clear();
		setVisible(true);
	}
	
	public void print(String text) {
		output.append(text);
	}
	
	public void println(String text) {
		output.append(text + "\n");
	}
	
	public void adjustSize() {
		pack();
		if(this.getHeight() > Toolkit.getDefaultToolkit().getScreenSize().getHeight())
			this.setSize(this.getWidth() + 50, (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 100);
		setLocationRelativeTo(null);
	}
	
	public void clear() {
		output.setText("");
	}
}
